package com.taotao.observer1;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: wangjin
 * @CreateTime: 2022-07-03  11:39
 */
public class IntegralSubject  implements  AbstractSubject{
    private List<Observer> observers=new ArrayList<>();
    @Override
    public void addObserver(Observer observer) {
        observers.add(observer);
    }

    @Override
    public void delObserver(Observer observer) {
        observers.remove(observer);
    }


    @Override
    public void notifyAll(String message) {
        observers.forEach(o->{
            o.update(message);
        });
    }
}
